<template>
  <div>
    <el-drawer ref="userDetailFrom" :visible.sync="dialogUserDetail" size="800px" @close="handleClose">
      <div slot="title" class="demo-drawer_title">
        <div class="con-head">
          <img :src="userDetailData.avatar" alt="" />
          <span class="nickname">{{ userDetailData.playerName }}</span>
        </div>
      </div>
      <div class="demo-drawer__content">
        <div class="description" v-if="userDetailData">
          <!-- Tabs -->
          <el-tabs type="border-card" v-model="tabsVal">
            <!-- 用户信息 -->
            <el-tab-pane name="1" label="用户信息">
              <div class="user-info">
                <div class="section">
                  <div class="section-hd">基本信息</div>
                  <div class="section-bd">
                    <div class="item">
                      <div>选手ID：</div>
                      <div class="value">{{ userDetailData.euserId }}</div>
                    </div>
                    <div class="item">
                      <div>选手邮箱：</div>
                      <div class="value">{{ userDetailData.emailAccount || '-' }}</div>
                    </div>
                    <div class="item">
                      <div>用户电话：</div>
                      <div class="value">{{ userDetailData.phone }}</div>
                    </div>
                    <div class="item">
                      <div>选手创建时间：</div>
                      <div class="value">{{ userDetailData.createTime }}</div>
                    </div>
                  </div>
                </div>
              </div>
            </el-tab-pane>
            <!-- 身份认证 -->
            <el-tab-pane name="2" label="身份认证">
              <el-table :data="balanceRecordData" size="small" class="mt20">
                <el-table-column prop="applyType" label="认证类型" min-width="100">
                  <template slot-scope="scope">
                    {{
                      scope.row.applyType == '1'
                        ? '个人'
                        : scope.row.applyType == '2'
                        ? '企业'
                        : scope.row.applyType == '3'
                        ? '学生'
                        : '-'
                    }}
                  </template>
                </el-table-column>
                <el-table-column label="身份证正面" width="100">
                  <template slot-scope="scope">
                    <div class="demo-image__preview line-heightOne">
                      <el-image
                        v-if="scope.row.idCardFront"
                        :src="scope.row.idCardFront"
                        :preview-src-list="[scope.row.idCardFront]"
                        fit="cover"
                      />
                      <span v-else>无</span>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column label="身份证背面" width="100">
                  <template slot-scope="scope">
                    <div class="demo-image__preview line-heightOne">
                      <el-image
                        v-if="scope.row.idCardEnd"
                        :src="scope.row.idCardEnd"
                        :preview-src-list="[scope.row.idCardEnd]"
                        fit="cover"
                      />
                      <span v-else>无</span>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column prop="applyType" label="姓名" min-width="100"></el-table-column>
                <el-table-column prop="idCard" label="身份证号" min-width="100"></el-table-column>
                <el-table-column prop="companyName" label="企业名称" min-width="100"></el-table-column>
                <el-table-column label="学生证" width="100">
                  <template slot-scope="scope">
                    <div class="demo-image__preview line-heightOne">
                      <el-image
                        v-if="scope.row.studentCard"
                        :src="scope.row.studentCard"
                        :preview-src-list="[scope.row.studentCard]"
                        fit="cover"
                      />
                      <span v-else>无</span>
                    </div>
                  </template>
                </el-table-column>

                <el-table-column label="营业执照" width="100">
                  <template slot-scope="scope">
                    <div class="demo-image__preview line-heightOne">
                      <el-image
                        v-if="scope.row.businessLicense"
                        :src="scope.row.businessLicense"
                        :preview-src-list="[scope.row.businessLicense]"
                        fit="cover"
                      />
                      <span v-else>无</span>
                    </div>
                  </template>
                </el-table-column>

                <el-table-column label="营业执照" width="100">
                  <template slot-scope="scope">
                    <div class="demo-image__preview line-heightOne">
                      <el-image
                        v-if="scope.row.authorization"
                        :src="scope.row.authorization"
                        :preview-src-list="[scope.row.authorization]"
                        fit="cover"
                      />
                      <span v-else>无</span>
                    </div>
                  </template>
                </el-table-column>

                <el-table-column prop="type" label="认证状态">
                  <template slot-scope="scope">
                    {{
                      scope.row.isApply == '1'
                        ? '审核中'
                        : scope.row.isApply == '2'
                        ? '审核通过'
                        : scope.row.isApply == '3'
                        ? '审核不通过'
                        : '-'
                    }}
                  </template>
                </el-table-column>
                <el-table-column width="200" prop="createTime" label="认证时间" />
              </el-table>
            </el-tab-pane>
            <!-- 佣金记录 -->
            <el-tab-pane name="3" label="作品列表">
              <el-table :data="brokerageRecordData" size="small" class="mt20">
                <el-table-column label="ID" prop="id" width="60" />
                <el-table-column label="内容标题" min-width="160" :show-overflow-tooltip="true">
                  <template slot-scope="scope">
                    <div>{{ scope.row.title | filterEmpty }}</div>
                  </template>
                </el-table-column>
                <el-table-column label="内容作者" prop="authorName" min-width="140" />
                <el-table-column label="内容类型" min-width="70">
                  <template slot-scope="scope">
                    <div>{{ scope.row.type === 1 ? '图文' : '视频' }}</div>
                  </template>
                </el-table-column>
                <el-table-column label="封面" min-width="50px">
                  <template slot-scope="scope">
                    <div class="demo-image__preview line-heightOne">
                      <el-image :src="scope.row.cover" class="mr5 imgStyle" :preview-src-list="[scope.row.cover]" />
                    </div>
                  </template>
                </el-table-column>
                <el-table-column label="推荐级别" min-width="130">
                  <template slot-scope="scope">
                    <el-rate disabled v-model="scope.row.star"> </el-rate>
                  </template>
                </el-table-column>
                <el-table-column prop="likeNum" label="点赞数" min-width="100" />
                <el-table-column prop="replyNum" label="评论数" min-width="100" />
                <el-table-column prop="categoryName" label="分类" min-width="100" />
                <el-table-column label="话题" min-width="130" :show-overflow-tooltip="true">
                  <template slot-scope="scope">
                    <div v-if="scope.row.topicList && scope.row.topicList.length > 0" class="topic-list">
                      <el-tag
                        v-for="(item, i) in scope.row.topicList"
                        :key="i"
                        size="small"
                        class="topic-tag"
                        :type="getTopicTagType(i)"
                      >
                        #{{ item }}
                      </el-tag>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column label="评论" min-width="90">
                  <template slot-scope="scope">
                    <div>{{ scope.row.replyStatus | communityReplyStatusFilter }}</div>
                  </template>
                </el-table-column>
                <el-table-column label="审核状态" min-width="100">
                  <template slot-scope="scope">
                    <el-tag class="doingTag tag-background" v-if="scope.row.auditStatus === 0">待审核</el-tag>
                    <el-tag class="endTag tag-background" v-if="scope.row.auditStatus === 1">审核成功</el-tag>
                    <el-tag class="notStartTag tag-background" v-if="scope.row.auditStatus === 2">审核失败</el-tag>
                    <el-tag type="danger" v-if="scope.row.auditStatus === 3">平台关闭</el-tag>
                  </template>
                </el-table-column>
                <!-- <el-table-column
                  v-if="tabActive === '10'"
                  prop="refusal"
                  label="拒绝原因"
                  min-width="120"
                  :show-overflow-tooltip="true"
                >
                  <template slot-scope="scope">
                    <div v-if="Number(scope.row.auditStatus) > 1">{{ scope.row.refusal }}</div>
                    <div v-else>无</div>
                  </template>
                </el-table-column> -->
                <el-table-column prop="createTime" label="发布时间" min-width="150" />
              </el-table>
            </el-tab-pane>
          </el-tabs>
          <div class="block" v-if="tabsVal != '1'">
            <el-pagination
              :page-size="paginationData.limit"
              :total="paginationData.total"
              :current-page="paginationData.page"
              @size-change="handleSizeChange"
              @current-change="pageChange"
              background
              :page-sizes="[10, 20, 30, 40]"
              layout="total, sizes, prev, pager, next, jumper"
            />
          </div>
        </div>
      </div>
    </el-drawer>
  </div>
</template>

<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
  userDetailApi,
  userBalanceRecord,
  playerAuthHistoryApi,
  userBrokerageRecord,
  playerCreativePageApi,
} from '@/api/user';

export default {
  name: 'detailUser',
  props: {
    userNo: {
      type: Number,
      default: 0,
    },
    userDetailData: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      dialogUserDetail: false,
      // userDetailData: {},
      tabsVal: '1',
      balanceRecordData: [],
      brokerageRecordData: [],
      experienceRecordData: [],
      integralRecordData: [],
      signRecordData: [],
      paginationData: {
        page: 1,
        limit: 10,
        total: 0,
      },
    };
  },
  watch: {
    tabsVal(val) {
      this.paginationData.page = 1;
      this.getList(val);
    },
  },
  methods: {
    getList(val) {
      switch (val) {
        case '2':
          this.getBalabceRecord();
          break;
        case '3':
          this.getBrokerageRecord();
          break;
      }
    },
    getUserDetail(id) {
      // userDetailApi(id).then((res) => {
      //   this.userDetailData = res;
      // });
    },
    //获取佣金记录列表
    getBrokerageRecord() {
      playerCreativePageApi({
        euserId: this.userDetailData.euserId,
        page: this.paginationData.page,
        limit: this.paginationData.limit,
      }).then((res) => {
        this.brokerageRecordData = res.list;
        this.paginationData.total = res.total;
      });
    },
    // 获取话题标签类型，循环使用不同颜色
    getTopicTagType(index) {
      const types = ['primary', 'success', 'warning', 'danger', 'info', ''];
      return types[index % types.length];
    },
    //获取余额记录列表
    getBalabceRecord() {
      playerAuthHistoryApi({
        euserId: this.userDetailData.euserId,
      }).then((res) => {
        this.balanceRecordData = res.list;
        this.paginationData.total = res.total;
      });
    },
    handleSizeChange(val) {
      this.paginationData.limit = val;
      this.getList(this.tabsVal);
    },
    pageChange(val) {
      this.paginationData.page = val;
      this.getList(this.tabsVal);
    },
    handleClose() {
      this.dialogUserDetail = false;
      this.tabsVal = '1';
    },
  },
};
</script>

<style scoped lang="scss">
::v-deep .el-drawer__header {
  display: flex !important;
  align-items: flex-start !important;
  margin: 0 !important;
  padding: 15px 15px 0 15px !important;
}
::v-deep .demo-drawer_title {
  width: 90%;
}
::v-deep .el-drawer__body {
  padding: 0 0 30px 0 !important;
}
.InvoiceList {
  ::v-deep.el-collapse-item__header {
    font-size: 12px;
    color: #606266;
  }
}

.wrapper {
  background-color: #fff;
  margin-top: 7px;
  padding: 10px 12px;
  &-num {
    font-size: 10px;
    color: #999999;
  }

  &-title {
    color: #666666;
    font-size: 12px;
  }

  &-img {
    width: 60px;
    height: 60px;
    margin-right: 10px;
    border-radius: 7px;
    overflow: hidden;
    margin-bottom: 10px;

    image {
      width: 100%;
      height: 100%;
    }

    &:nth-child(5n) {
      margin-right: 0;
    }
  }
}

.title {
  font-size: 36px;
}

.demo-drawer__content {
  // padding: 0 30px;
  overflow: hidden;
}

.demo-image__preview {
  display: inline-block;
  .el-image {
    width: 50px;
    height: 50px;
  }
}

.logistics {
  align-items: center;
  padding: 10px 0px;
  .logistics_img {
    width: 45px;
    height: 45px;
    margin-right: 12px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .logistics_cent {
    span {
      display: block;
      font-size: 12px;
    }
  }
}

.trees-coadd {
  width: 100%;
  height: 400px;
  border-radius: 4px;
  overflow: hidden;
  .scollhide {
    width: 100%;
    height: 100%;
    overflow: auto;
    margin-left: 18px;
    padding: 10px 0 10px 0;
    box-sizing: border-box;
    .content {
      font-size: 12px;
    }

    .time {
      font-size: 12px;
      color: var(--prev-color-primary);
    }
  }
}

.title {
  margin-bottom: 14px;
  color: #303133;
  font-weight: 500;
  font-size: 14px;
}

.description {
  &-term {
    display: table-cell;
    padding-bottom: 5px;
    line-height: 20px;
    width: 50%;
    font-size: 12px;
    color: #606266;
  }
  ::v-deep .el-divider--horizontal {
    margin: 12px 0 !important;
  }
}
.description-term img {
  width: 60px;
  height: 60px;
}
.description-term {
  display: flex;
  align-items: center;
}
.con-head {
  padding: 10px 30px;
  display: flex;
  align-items: center;
  img {
    width: 60px;
    height: 60px;
    margin-right: 15px;
    border-radius: 50%;
  }
  .nickname {
    font-weight: 500;
    font-size: 16px;
    line-height: 16px;
    color: rgba(0, 0, 0, 0.85);
  }
}

.info-row {
  flex-wrap: nowrap;
  padding: 20px 35px 24px 30px;
  border-bottom: 1px dashed #eee;

  &-item {
    flex: none;
    width: 155px;
    font-size: 14px;
    line-height: 14px;
    color: rgba(0, 0, 0, 0.85);

    &-title {
      margin-bottom: 12px;
      font-size: 13px;
      line-height: 13px;
      color: #666666;
    }
  }
}
.user-info {
  .section {
    padding: 25px 0;

    &-hd {
      padding-left: 10px;
      border-left: 3px solid var(--prev-color-primary);
      font-weight: 500;
      font-size: 14px;
      line-height: 16px;
      color: #303133;
    }

    &-bd {
      display: flex;
      flex-wrap: wrap;
    }

    .item {
      width: 30%;
      // flex: 0 0 calc(~"(100% - 60px) / 3");
      display: flex;
      margin: 16px 30px 0 0;
      font-size: 13px;
      color: #606266;

      &:nth-child(3n + 3) {
        margin: 16px 0 0;
      }
    }

    .value {
      flex: 1;
    }
    .avatar {
      width: 60px;
      height: 60px;
      overflow: hidden;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
}
.section-hd-other {
  padding-left: 10px;
  border-left: 3px solid var(--prev-color-primary);
  font-weight: 500;
  font-size: 14px;
  line-height: 16px;
  color: #303133;
}
::v-deep .el-tabs__content {
  padding: 0 30px !important;
}
</style>
